package com.rizzo.analytics.domain.quota;

import com.rizzo.infrastructure.web.validator.Save;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

import javax.validation.constraints.NotNull;
import java.io.Serializable;

public class Quota implements Serializable {

	private static final long serialVersionUID = 1L;

	@NotNull(message = "quota.method.field.required", groups = {Save.class})
	private String method;

	private long hits = 1;

	public Quota() {
	}

	public Quota(String method, long hits) {
		this.method = method;
		this.hits = hits;
	}

	public String getMethod() {
		return method;
	}

	public void setMethod(String method) {
		this.method = method;
	}

	public long getHits() {
		return hits;
	}

	public void setHits(long hits) {
		this.hits = hits;
	}

	@Override
	public boolean equals(Object other) {
		return EqualsBuilder.reflectionEquals(other, this);
	}

	@Override
	public int hashCode() {
		return HashCodeBuilder.reflectionHashCode(this);
	}

	@Override
	public String toString() {
		return new ToStringBuilder(this).
				append("hits", hits).
				append("method", method).
				toString();
	}
}

